using System;
using System.Drawing;
using System.Xml;

namespace FreeFlow.Client
{
  /// <summary>Rule border style.</summary>
  public enum RuleStyle
  {
    /// <summary>Lowered border.</summary>
    Lowered, 
    /// <summary>Raised border.</summary>
    Raised, 
    /// <summary>No border.</summary>
    Flat
  }

	/// <summary>A rule field.</summary>
  [Serializable]
  public class RuleField : Field
  {
    internal RuleField(Form form, XmlElement fieldNode)
      : base(form, fieldNode)
    {
      if (fieldNode != null)
      {
        if (fieldNode.Attributes[ColourAttribute] != null)
          color = ParseColor(fieldNode.Attributes[ColourAttribute].Value);
        if (fieldNode.Attributes["Style"] != null)
        {
          string ruleStyle = fieldNode.Attributes["Style"].Value;
          if (ruleStyle == "Raised")
            style = RuleStyle.Raised;
          else if (ruleStyle == "Lowered")
            style = RuleStyle.Lowered;
          else if (ruleStyle == "Flat")
            style = RuleStyle.Flat;
          else
            throw new FreeFlowException("Unrecognized rule style - " + ruleStyle);
        }
      }
    }

    #region properties
    private Color color;
    /// <summary>
    /// Gets the color of the rule.
    /// </summary>
    public Color Color
    {
      get { return color; }
    }

    private RuleStyle style;
    /// <summary>
    /// Gets the rule's border style.
    /// </summary>
    public RuleStyle Style
    {
      get { return style; }
    }
    #endregion

    internal override bool ShouldAddToFieldInput()
    {
      return false;
    }
	}
}
